package de.wbh.gwt.form.layouter.shared.area;

import javax.inject.Inject;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

import de.wbh.gwt.form.layouter.shared.Step;
import de.wbh.gwt.form.layouter.shared.activity.ActivityFactory;
import de.wbh.gwt.form.layouter.shared.place.CreateConfigurationPlace;
import de.wbh.gwt.form.layouter.shared.place.EditPlace;

public class Deck2LeftAreaActivityMapper implements ActivityMapper {

	private final ActivityFactory activityFactory;

	@Inject
	public Deck2LeftAreaActivityMapper(ActivityFactory activityFactory) {
		this.activityFactory = activityFactory;
	}

	@Override
	public Activity getActivity(Place place) {
		if (place instanceof CreateConfigurationPlace) {
			Step step = ((CreateConfigurationPlace) place).getStep();
			return this.activityFactory.getLoadStepsActivity(step);
		} else if (place instanceof EditPlace)
			return this.activityFactory.getFieldsActivity(((EditPlace) place).getEfdName());
		return null;
	}

}
